//
//  pcap_engine_libpcap.h
//  testpcap
//
//  Created by bugforever on 1/10/15.
//  Copyright (c) 2015 bugforever. All rights reserved.
//

#ifndef __pcap_engine_h
#define __pcap_engine_h

#include "../utility/base_thread.h"
#include "../network_filter/network_filter_base.h"
#include "../device_retriever/device_retriever.h"

#ifdef _WIN32
#include "../../ThirdParty/WpdPack/Include/pcap.h"
#else
#include "../../ThirdParty/libpcap-1.6.2/pcap.h"
#endif

class pcap_engine
:public base_thread
,public network_filter_base
{
public:
    pcap_engine();
    virtual ~pcap_engine();
    
    bool start_engine( device_info * ptr_info );
    bool stop_engine();
    
    virtual void thread_function();
    
    virtual void process_network_data( FILTER_ACCEPT_DATATYPE type , void * ptr_data );
    
    static void pcap_handler(u_char *user, const struct pcap_pkthdr *h, const u_char *bytes);
    
    
private:
    device_info m_capture_device;
    pcap_t * m_handle_pcap;
    
    int m_link_type;
};

#endif /* defined(__testpcap__pcap_engine_libpcap__) */
